<template>
	<div>
		<div style="margin-top: 20%;">
			<van-field v-model="back_num" label="退库数量" placeholder="请输入退库数量" @input="back_num_input"/>
		</div>
		<div style="margin-top: 10%;">
			<van-button color="#4142F4" type="primary" block @click="back_issue()">退库</van-button>
		</div>
	</div>
</template>

<script>
	import { BaseUrl } from '@/util/util.js';
	const PrefixUrl = BaseUrl();
	export default {
		data(){
			return{
				back_num: '',
				issue_id: ''
			}
		},
		onLoad: function(option) {
			this.issue_id = option.id
		},
		created() {
			
		},
		methods:{
			back_num_input(event){
				this.back_num = event.detail
			},
			back_issue(){
				uni.request({
					method: 'POST',
					url: PrefixUrl + '/equimentIssue/backIssue',
					data: {
						id: this.issue_id,
						num: this.back_num
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'token': uni.getStorageSync('token')
					},
					success: (res) => {
						if(res.data.obj){
							uni.navigateBack({
								delta: 1
							});
							uni.showToast({
								title: '退库成功!',
								mask: true,
								icon: 'none'
							})
						}else {
							uni.showToast({
								title: '出库失败，请联系科信部!',
								mask: true,
								icon: 'none'
							})
						}
					}
				});
			}
		}
	} 
</script>

<style>
</style>